package cn.edu.scnu.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration//注册为配置类，为Bean方法创建对象
public class MPConfig {
    @Bean//交给spring管理
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //创建一个拦截器容器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //创建真正的分页拦截器并加入容器中
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        //返回拦截器容器
        return interceptor;
    }
}
